package com.zhiwen.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhiwen.domain.entity.Category;
import com.zhiwen.mapper.CategoryMapper;
import com.zhiwen.service.CategoryService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 分类服务实现类
 */
@Service
public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> implements CategoryService {

    @Override
    public List<Category> getAllVisibleCategories() {
        // 查询所有可见的分类
        LambdaQueryWrapper<Category> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Category::getVisible, 1);
        wrapper.eq(Category::getDeleted, 0);
        wrapper.orderByAsc(Category::getSort);

        return list(wrapper);
    }
}
